<%-- 
    Document   : question-all-category
    Created on : Feb 9, 2012, 8:12:43 AM
    Author     : PhucAn
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Question categories</title>       

        <script>
            function setValue(identifier){
                //set value for hidden field. This field hold the 'id' value of selected item                
                document.getElementById("selected-item-id").value=identifier;               
            }
            
        </script>
    </head>
    <body>      
        <c:if test="${list.size()==0}">
            <jsp:include page="/page/empty-list.jsp"/>
        </c:if>
        <c:if test="${list.size()>0}">
            <form method="post" action="#">
                <table class="data-table">
                    <tr>
                        <th>Name</th>
                        <th>Description</th>
                        <th></th>
                        <th></th>
                    </tr>  
                    <c:forEach var="cate" items="${list}">
                    <tr>
                        <td>${cate.name}</td>
                        <td>${cate.description}</td>
                        <td><a href="QuestionAction.do?method=manage&cateid=${cate.name}">Add question</a></td>
                        <td><input type="button" name="set-value" value="Delete" onclick='showConfirm();setValue(${cate.id});'/></td>
                    </tr>                    
</c:forEach>
                </table>              
                <input type="hidden" id="selected-item-id" name="selected-item-id" value=""/>
                <div class="confirm-box">
                    <div>Are you sure want to continue?</div>
                    <input type="submit" name="remove" onclick="hideConfirm();" value="Delete"/>
                    <input type="button" value="Cancel"/>
                </div>
            </form>
            <form method="post" action="QuestionCategoryAction.do?method=add">
                <table class="form-table">
                    <tr>
                        <td>Category name:</td>
                        <td><input type="text" name="name"/></td>
                        <td></td>
                    </tr>
                    <tr>
                        <td>Description: </td>
                        <td><input type="text" name="description"/></td>
                        <td></td>
                    </tr>
                    <tr>
                        <td></td>
                        <td colspan="2"><input type="submit" name="add" value="Create"/></td>
                    </tr>
                </table>                
            </form>
      </c:if>
    </body>
</html>

